define(function(require, exports, module) {
    var ALL = require("../../common/all"),
        CONFIG = ALL.CONFIG,
        METHOD = ALL.METHOD,
        Dialog = ALL.Dialog,
        Init = ALL.Init;

    var _Dialog = new Dialog({
        title : "提示",
        content : "<p>是否确定添加/修改？</p>",
        text4Btn: ["确定"],
        class4Btn: [""]
    });

    var _vm = Init.initVue({
        data : {
            id : null,
            check: {},
            user_id : '',
            disabled : false,
            res: {
                trade_no : '',
                user_name : '',
                minimum : '',
            }
        },
        methods: {
            submit : function() {
                var obj = {
                    user_id : _vm.user_id,
                    minimum : _vm.res.minimum
                }, flag, url;

                this.check.$valid();
                flag = this.check.flag;

                if (!flag) { return; }

                if (_vm.id) {
                    _Dialog.changeCfg({content : "<p>是否确定修改？</p>"});
                    url = "withdrawblist/update";
                    obj.wb_id = _vm.id;
                } else {
                    _Dialog.changeCfg({content : "<p>是否确定添加？</p>"});
                    url = "withdrawblist/create";
                }

                _Dialog.showUI(function(i) {
                    if (i == 0) {
                        METHOD.loading.show();
                        METHOD.ajax(url,obj,{type : 'post'}).done(function(){
                            METHOD.alert("操作成功").done(function(){
                                window.location.href = "../control/withdraw.html";
                            });
                            METHOD.loading.hide();
                        }).fail(function(){
                            METHOD.loading.hide();
                        })
                    };
                    this.hideUI();
                });
            },
            getInfoCallback : function(o) {
                if (o) {
                    this.user_id = o.id;
                    this.res.user_name = o.name;
                } else {
                    this.user_id = "";
                    this.res.user_name = "";
                }
            }
        }
    });

    _vm.id = METHOD.getQueryParms("id") || null;

    if (_vm.id) {
        METHOD.loading.show();
        METHOD.ajax("withdrawblist/detail",{wb_id:_vm.id}).done(function(json){
            METHOD.loading.hide();
            _vm.res = json.data;
            _vm.disabled = true;
        }).fail(function(){
            METHOD.loading.hide();
        })
    }

});

